home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-01 | 24.5 KB | 896 lines | [TEXT/MPS ] |
- // UDocument.cp
- // Copyright © 1984-1991 by Apple Computer Inc. All rights reserved.
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __PACKAGES__
- #include <Packages.h>
- #endif
-
- #ifndef __UDESIGNATOR__
- #include <UDesignator.h>
- #endif
-
- #ifndef __UAPPLICATION__
- #include <UApplication.h>
- #endif
-
- #ifndef __UCLIPBOARDMGR__
- #include <UClipboardMgr.h>
- #endif
-
- #ifndef __UPRINTHANDLER__
- #include <UPrintHandler.h>
- #endif
-
- #ifndef __UWINDOW__
- #include <UWindow.h>
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __UERRORMGR__
- #include <UErrorMgr.h>
- #endif
-
- #ifndef __UMENUMGR__
- #include <UMenuMgr.h>
- #endif
-
- #ifndef __UMACAPPGLOBALS__
- #include <UMacAppGlobals.h>
- #endif
-
- #ifndef __USTREAM__
- #include <UStream.h>
- #endif
-
- #ifndef __UVIEWSERVER__
- #include <UViewServer.h>
- #endif
-
- #ifndef __UDOCUMENT__
- #include <UDocument.h>
- #endif
-
- //--------------------------------------------------------------------------------------------------
- short gNumUntitled = 1; // call the first document "Untitled-1"
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- CWindowIterator::CWindowIterator(TDocument* itsDocument,
- ArrayIndex itsLowBound,
- ArrayIndex itsHighBound,
- Boolean itsForward) :
- CObjectIterator(itsDocument ? itsDocument->fWindowList : NULL, itsLowBound, itsHighBound, itsForward)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- CWindowIterator::CWindowIterator(TDocument* itsDocument,
- Boolean itsForward) :
- CObjectIterator(itsDocument ? itsDocument->fWindowList : NULL, itsForward)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- CWindowIterator::CWindowIterator(TDocument* itsDocument) :
- CObjectIterator(itsDocument ? itsDocument->fWindowList : NULL)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- TWindow* CWindowIterator::CurrentWindow(void)
- {
- return (TWindow *)this->CurrentObject();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- TWindow* CWindowIterator::FirstWindow(void)
- {
- return (TWindow*)this->FirstObject();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- TWindow* CWindowIterator::NextWindow(void)
- {
- return (TWindow*)this->NextObject();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAWriteFile
-
- pascal void TSaveDocCommand::DoIt(void)
- {
- fChangedDocument->SaveDocument(fID);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MASelCommand
- pascal void TSaveDocCommand::Initialize(void) // override
- {
- inherited::Initialize();
- fChangedDocument = NULL;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- pascal void TSaveDocCommand::ISaveDocCommand(CmdNumber itsCmdNumber,
- TDocument* itsDocument)
- {
- this->INoChangesCommand(itsCmdNumber, itsDocument, NULL);
- fChangedDocument = itsDocument;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAFields
-
- pascal void TSaveDocCommand::Fields(TObject* obj)// override
- {
- obj->DoToField("TSaveDocCommand", (Ptr)NULL, bClass);
- inherited::Fields(obj);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAReadFile
-
- pascal void TRevertDocCommand::DoIt(void)
- {
- Str255 name;
- FailInfo fi;
-
- fChangedDocument->GetTitle(name);
- ParamText(name, "", "", "");
- //!!! This should be programatically defeatable
- if (MacAppAlert(phRevert, NULL) == kYesButton)
- {
- if (fi.Try())
- {
- fChangedDocument->RevertDocument();
- fi.Success();
- }
- else // Recover
- {
- fChangedDocument->ShowReverted(); // make sure screen is updated
- fi.ReSignal();
- }
- fChangedDocument->ShowReverted();
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MASelCommand
- pascal void TRevertDocCommand::Initialize(void) // override
- {
- inherited::Initialize();
- fChangedDocument = NULL;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- pascal void TRevertDocCommand::IRevertDocCommand(CmdNumber itsCmdNumber,
- TDocument* itsDocument)
- {
- this->INoChangesCommand(itsCmdNumber, itsDocument, NULL);
- fChangedDocument = itsDocument;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAFields
-
- pascal void TRevertDocCommand::Fields(TObject* obj)// override
- {
- obj->DoToField("TRevertDocCommand", (Ptr)NULL, bClass);
-
- inherited::Fields(obj);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
- pascal void TDocument::Initialize(void) // override
- {
- inherited::Initialize();
-
- fTitle = "";
- fWindowList = NULL;
- fViewList = NULL;
- fPrintInfo = NULL;
- fSavePrintInfo = TRUE;
- fSharePrintInfo = TRUE;
- fReopenAlert = TRUE;
- fCommitOnSave = TRUE;
- fChangeCount = 0;
- fUserSelection = NULL;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::IDocument(void)
- {
- FailInfo fi;
-
- this->IEvtHandler(gApplication);
-
- if (fi.Try())
- {
- fWindowList = NewList();
- #if qDebug
- fWindowList->SetEltType("TWindow");
- #endif
-
- fViewList = NewList();
- #if qDebug
- fViewList->SetEltType("TView");
- #endif
-
- fi.Success();
- }
- else // Recover
- {
- this->Free();
- fi.ReSignal();
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal void TDocument::Free(void) // override
-
- {
- gApplication->DeleteDocument(this);
-
- fWindowList = (TList *)FreeListIfObject(fWindowList);
- fViewList = (TList *)FreeListIfObject(fViewList);
-
- if (fSharePrintInfo)
- fPrintInfo = DisposeIfHandle(fPrintInfo);
- else
- fPrintInfo = NULL; // Always drop my reference
-
- fUserSelection = (TDesignator *)FreeIfObject(fUserSelection);
-
- inherited::Free();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::AddView(TView* aView)
- {
- // Protect against double installation and keep in synch with window list
-
- if (fViewList && (fViewList->GetIdentityItemNo(aView) == 0))
- fViewList->Insert(aView);
-
- if (fWindowList && aView && aView->IsMemberClass(GetClassIDFromName("TWindow")))
- if (fWindowList->GetIdentityItemNo(aView) == 0)
- fWindowList->Insert(aView);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::AddWindow(TWindow* aWindow)
- {
- // Protect against double installation and keep in synch with window list
- // doesn't already exist in list
- if (fWindowList && (fWindowList->GetIdentityItemNo(aWindow) == 0))
- fWindowList->Insert(aWindow);
-
- // ??? should we only have one list now… maybe created on demand? (post 2.0) */
- if (fViewList && (fViewList->GetIdentityItemNo(aWindow) == 0))
- fViewList->Insert(aWindow);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
-
- pascal Boolean TDocument::AlreadyOpen(TFile*)
- {
- return FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::AttachPrintHandler(TPrintHandler* itsPrintHandler)
- {
- if (itsPrintHandler)
- itsPrintHandler->fDocument = this;
-
- TPrintMenuBehavior* aPrintMenuBehavior = new TPrintMenuBehavior;
- aPrintMenuBehavior->IPrintMenuBehavior(itsPrintHandler);
- this->AddBehavior(aPrintMenuBehavior);
- if (!fPrintInfo && fSharePrintInfo)
- fPrintInfo = itsPrintHandler->GetPrintInfo();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::DetachPrintHandler(TPrintHandler* itsPrintHandler)
- {
- CBehaviorIterator iter(this);
-
- for (TBehavior* aBehavior = iter.FirstBehavior(); iter.More(); aBehavior = iter.NextBehavior())
- if (aBehavior->IsMemberClass(GetClassIDFromName("TPrintMenuBehavior")) &&
- ((TPrintMenuBehavior*)aBehavior)->fPrintHandler == itsPrintHandler)
- {
- this->RemoveBehavior(aBehavior);
- aBehavior->Free();
- break;
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MARes
- pascal void TDocument::Changed(ChangeID theChange,
- TObject* changedBy)// override
- {
- switch (theChange)
- {
- case cUndo:
- --fChangeCount;
- break;
- default:
- // protect from rollover (it goes negative). If your document has
- // this many changes (over 2 billion you are truly sick!
- this->SetChangeCount(Max(this->GetChangeCount() + 1, 1));
- break;
- }
- inherited::Changed(theChange, changedBy); // Notify dependents
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- short TDocument::OpenWindowCount(void)
- {
- short openDocWindows = 0;
- CWindowIterator iter(this);
-
- // See how many open windows this document has
- for (TWindow* aWindow = iter.FirstWindow(); iter.More(); aWindow = iter.NextWindow())
- if (aWindow->IsShown())
- ++openDocWindows;
- return openDocWindows;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal void TDocument::CloseView(TView* aView)
- {
- if (aView && (aView->fDocument == this)) // free window
- {
- // !!! Yuch!, of course we should be able to ASK any view if it would like to close
- // its associated document and maybe even what doc it would like to close.
- // Some other time…
- if (aView->IsMemberClass(GetClassIDFromName("TWindow")) && ((TWindow *)aView)->fClosesDocument || (this->OpenWindowCount() <= 1))
- this->Close(); // The view will be closed and freed as a side effect
-
- else
- aView->Close();
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal void TDocument::Close(void)
- {
- TCommand * lastCommand;
- short poseResult;
- long changeCount;
-
- #if qDebug
- if (gClipboardMgr->fClipWindow->fDocument == this)
- ProgramBreak("Attempt to close clipboard document");
- #endif
-
- changeCount = this->GetChangeCount();
- if (changeCount)
- {
- poseResult = this->PoseSaveDialog();
- if (poseResult == cancel)
- Failure(noErr, msgCancelled);
- }
-
- lastCommand = this->GetLastCommand();
- if (lastCommand && (lastCommand->fChangedObject == this))
- this->CommitLastCommand();
-
- if (changeCount)
- {
- if (poseResult == kYesButton)
- this->SaveDocument(cClose); // Will fail if unable to save
- else if (poseResult == kNoButton)
- this->Abandon();
- }
-
- // Must never be called for a document related to a view in the Clipboard.
- // Why is this???
- CWindowIterator iter(this);
-
- for (TWindow* aWindow = iter.FirstWindow(); iter.More(); aWindow = iter.NextWindow())
- aWindow->Close();
-
- this->Free();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal void TDocument::DeleteView(TView* viewToDelete)
- {
- if (fViewList)
- fViewList->Delete(viewToDelete);
-
- // Make sure the lists are in synch. ??? should we only have one list now (post 2.0)
- if (fWindowList)
- fWindowList->Delete(viewToDelete);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal void TDocument::DeleteWindow(TWindow* windowToDelete)
- {
- if (fWindowList)
- fWindowList->Delete(windowToDelete);
-
- // Make sure the lists are in synch. ??? should we only have one list now (post 2.0)
- if (fViewList)
- fViewList->Delete(windowToDelete);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- // Called for 'New' && 'Revert' [to blank] commands && for default open tool icon
- pascal void TDocument::DoInitialState(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::DoMakeViews(Boolean forPrinting)
-
- // E X A M P L E
- // {
- // TYOURView* aYOURView;
- // aYOURView = new TYourView;
- // aYOURView->IYOURView(this, YOURExtentRect);
- // return aYOURView;
- // }
-
- {
- if (qTemplateViews)
- {
- TView * aView = NULL;
-
- if (forPrinting) // Don't need window when Finder printing.
- aView = gViewServer->DoCreateViews(this, NULL, kDefaultViewID, gZeroVPt);
- else
- aView = gViewServer->NewTemplateWindow(kDefaultWindowID, this);
-
- // Install a copy of gPrintHandler into the view. gPrintHandler will be a real printhandler
- // if UPrinting has been initialized otherwise it is a null print handler.
- aView = aView->FindSubView(kIDDefaultView);
- TPrintHandler* aPrintHandler = (TPrintHandler *)gPrintHandler->Clone();
-
- aPrintHandler->fView = aView;
- aPrintHandler->SetDefaultPrintInfo();
- this->AttachPrintHandler(aPrintHandler);
- if (aView)
- aView->AttachPrintHandler(aPrintHandler);
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::DoMakeWindows(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MASelCommand
-
- pascal void TDocument::DoMenuCommand(CmdNumber aCmdNumber)
- {
- TSaveDocCommand * aSaveDocCommand;
- TRevertDocCommand * aRevertDocCommand;
- Boolean oldObjectPerm;
-
- /* ==================================================================================
- Some commands will be posted to perform actions that must _ALWAYS_ be available.
- The allocation cannot be allowed to fail. So we do a temp allocation which by
- definition cannot be allowed to fail. This strategy is used wherever we want to use
- command objects but don't want to leave the user twisting in the breeze.
- NOTE: Don't forget to allow for this memory in your mem! resource if you copy this
- style in your own code.
- ================================================================================== */
-
- switch (aCmdNumber)
- {
- case cSave:
- case cSaveAs:
- case cSaveCopy:
- oldObjectPerm = AllocateObjectsFromPerm(FALSE);
- aSaveDocCommand = new TSaveDocCommand;
- AllocateObjectsFromPerm(oldObjectPerm);
-
- aSaveDocCommand->ISaveDocCommand(aCmdNumber, this);
- this->PostCommand(aSaveDocCommand);
- break;
-
- case cRevert:
- oldObjectPerm = AllocateObjectsFromPerm(FALSE);
- aRevertDocCommand = new TRevertDocCommand;
- AllocateObjectsFromPerm(oldObjectPerm);
-
- aRevertDocCommand->IRevertDocCommand(aCmdNumber, this);
- this->PostCommand(aRevertDocCommand);
- break;
-
- default:
- inherited::DoMenuCommand(aCmdNumber);
- break;
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::DoSetupMenus(void)
- {
- inherited::DoSetupMenus();
-
- Enable(cSaveAs, TRUE);
- Enable(cSaveCopy, TRUE);
- if (this->GetChangeCount())
- {
- Enable(cSave, TRUE);
- Enable(cRevert, TRUE);
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::ForAllViewsDo(pascal void(* DoToView)(TView* aView,
- void* staticLink), void* staticLink)
- {
- CObjectIterator iter(fViewList);
-
- for (TView* aView = (TView*)iter.FirstObject(); iter.More(); aView = (TView*)iter.NextObject())
- DoToView(aView, staticLink);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::ForAllWindowsDo(DoToWindType DoToWind,
- void* staticLink)
- {
- CWindowIterator iter(this);
-
- for (TWindow* aWindow = iter.FirstWindow(); iter.More(); aWindow = iter.NextWindow())
- DoToWind(aWindow, staticLink);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::FreeData(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClipboard
-
- pascal void TDocument::FreeFromClipboard(void)
- {
- this->DeleteWindow(gClipboardMgr->fClipWindow);
-
- this->Free();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal long TDocument::GetChangeCount(void)
- {
- return fChangeCount;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAInspector
-
- pascal void TDocument::GetInspectorName(Str255& inspectorName)// override
- {
- inspectorName = fTitle;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::DoWriteData(const OSType /* aScrapType */,
- TDesignator* /* aDesignator */,
- TStream* /* aStream */)
- {
- this->SubClassResponsibility();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::DoReadData(const OSType /* aScrapType */,
- TDesignator* /* aDesignator */,
- TStream* /* aStream */,
- long /* count */)
- {
- this->SubClassResponsibility();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- pascal TDesignator* TDocument::GetUserSelection(void)
- {
- return fUserSelection;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- pascal void TDocument::SetUserSelection(TDesignator* newSelection)
- {
- fUserSelection = (TDesignator *)FreeIfObject(fUserSelection);
- fUserSelection = newSelection;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- pascal void TDocument::UserSelectionChanged(void)
- {
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentNonRes
-
- pascal void TDocument::RevealSelection(TDesignator*)
- {
- // Default behavior: select the first window of the application.
- // Call inherited::RevealSelection() to get this default behavior if you need it.
-
- if (fWindowList)
- {
- TWindow * window = (TWindow *)fWindowList->First();//??? this seems funky
- window->Select();
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::OpenAgain(CmdNumber,
- TDocument*)
- {
- TWindow * window;
- Str255 name;
-
- name = fTitle; // because ParamText allocates memory
- ParamText(name, "", "", "");
-
- if (fReopenAlert)
- StdAlert(phReopenDoc); //!!! This should be programatically defeatable
-
- if (fWindowList)
- {
- window = (TWindow *)fWindowList->First();//??? this seems funky
- window->Select();
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal short TDocument::PoseSaveDialog(void)
- {
- short idx;
- Str255 name;
- Str255 reason;
- Str255 apName;
- short apRefNum;
- Handle apParam;
-
- if (this->GetChangeCount())
- {
- if (gApplication->fAppDone)
- idx = bzQuitting;
- else
- idx = bzClosing;
-
- GetIndString(reason, kIDBuzzString, idx);
- name = fTitle; // ParamText can compact heap
- GetAppParms(apName, apRefNum, apParam); // Get the application name
- ParamText(name, reason, apName, "");
- return MacAppAlert(phSaveChanges, NULL);//!!! This should be programatically
- }
- else
- return kNoButton;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAReadFile
-
- pascal void TDocument::ReadDocument(Boolean)
- {
- this->SubClassResponsibility();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAReadFile
-
- pascal void TDocument::RevertDocument(void)
- {
- this->SubClassResponsibility();
- }
-
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAClose
-
- pascal void TDocument::Abandon(void)
- {
- // If your document needs to do some cleanup when its being abandoned then
- // put some code in an override of this method
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAWriteFile
-
- pascal void TDocument::SaveDocument(CmdNumber)
- {
- this->SubClassResponsibility();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAWriteFile
-
- pascal void TDocument::SaveAgain(CmdNumber,
- TDocument* savingDoc)
- {
- // Don't save the file if another one of the same name is already open.
- if (savingDoc != this)
- Failure(errSaveAgain, 0);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::GetTitle(Str255& aTitle)
- {
- aTitle = fTitle;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::SetTitle(const Str255& aTitle)
- {
- CWindowIterator iter(this);
-
- fTitle = aTitle;
- for (TWindow* aWindow = iter.FirstWindow(); iter.More(); aWindow = iter.NextWindow())
- aWindow->SetTitleForDoc(aTitle);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MADocumentRes
-
- pascal void TDocument::SetChangeCount(long newChangeCount)
-
- // (??? should we add this as a default action with a TView.DocumentChanged method?)
- // You can notify your views that the document changed something like this:
- // pascal void NotifyChange(TView* aView)
- // {
- // if (aView && aView->IsMemberClass(GetClassIDFromName("TMyClass)))
- // ((TMyView)aView)->DocumentChanged(newChangeCount);
- // }
- {
- fChangeCount = newChangeCount;
- // this->ForAllViewsDo(NotifyChange);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAReadFile
-
- pascal void TDocument::ShowReverted(void)
- {
- CObjectIterator iter(fViewList);
-
- for (TView* aView = (TView*)iter.FirstObject(); iter.More(); aView = (TView*)iter.NextObject())
- aView->ShowReverted();
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal Boolean ShowAWindow(TWindow* aWindow, void*)
- {
- if (aWindow->fOpenInitially)
- aWindow->Open();
- return FALSE;
- }
-
- pascal void TDocument::ShowWindows(void)
- {
- // Make the windows open from back to front
- if (fWindowList)
- fWindowList->LastThat((TestObjectType)ShowAWindow, this);
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TDocument::UntitledName(Str255& noName)
- {
- short preInsert;
- short constChars;
- Str255 num;
-
- GetIndString(noName, kIDBuzzString, bzUntitled);
- if (ParseTitleTemplate(noName, preInsert, constChars))
- {
- NumToString(gNumUntitled, num);
-
- if (SubstituteInTitle(noName, num, preInsert, constChars))
- ++gNumUntitled;
- }
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAFields
-
- pascal void TDocument::Fields(TObject* obj)
- {
- obj->DoToField("TDocument", (Ptr)NULL, bClass);
- obj->DoToField("fTitle", (Ptr) & fTitle, bString);
- obj->DoToField("fWindowList", (Ptr) & fWindowList, bObject);
- obj->DoToField("fViewList", (Ptr) & fViewList, bObject);
- obj->DoToField("fChangeCount", (Ptr) & fChangeCount, bLongInt);
- obj->DoToField("fSavePrintInfo", (Ptr) & fSavePrintInfo, bBoolean);
- obj->DoToField("fSharePrintInfo", (Ptr) & fSharePrintInfo, bBoolean);
- obj->DoToField("fPrintInfo", (Ptr) & fPrintInfo, bHandle);
- obj->DoToField("fReopenAlert", (Ptr) & fReopenAlert, bBoolean);
- obj->DoToField("fCommitOnSave", (Ptr) & fCommitOnSave, bBoolean);
-
- inherited::Fields(obj);
- }
-
-
-